﻿/*
 * Twipler - Twitter Web Client with features.
 *  
 *  Copyright (C) 2009, 2010. Ian Quigley
 * 
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details. 
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>. 
 */

using System;
using System.Diagnostics;
using Twipler.Data.Access;

namespace Twipler.Data.Entity.Theme
{
    public class Container : BaseChild
    {
        [EditOrder(10)]
        public virtual string Name { get; set; }

        [EditOrder(20)]
        public virtual string Title { get; set; }

        [EditOrder(30)]
        [EditStringType(EditStringType.Types.LargeText)]
        public virtual string Source { get; set; }

        [EditReadonly]
        public virtual Design ParentDesign { get; set; }

        [EditIgnore]
        public override Base Parent
        {
            get { return ParentDesign; }
        }

        public override string ToString()
        {
            return Name;
        }

        public virtual Container Clone(Design parent)
        {
            Container newContainer = new Container()
            {
                Id = 0,
                Name = this.Name,
                ParentDesign = parent,
                Source = this.Source,
                Title = this.Title
            };

            Factory.Container.Save(newContainer);

            return newContainer;
        }
    }
}
